package cn.tedu.zhwy.cardealer.controller;

import cn.tedu.zhwy.base.response.JsonResult;
import cn.tedu.zhwy.cardealer.pojo.dto.CarportQuery;
import cn.tedu.zhwy.cardealer.pojo.dto.CarportSaveParam;
import cn.tedu.zhwy.cardealer.pojo.vo.CarportVO;
import cn.tedu.zhwy.cardealer.service.CarportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/carport")
@Slf4j
public class CarportController {

    @Autowired
    CarportService carportService;
    @GetMapping("select")
    public JsonResult selectCarport(CarportQuery carportQuery) {
        log.debug("查询车位信息: carportQuery={}",carportQuery);
        List<CarportVO> list = carportService.selectCarport(carportQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("save")
    public JsonResult saveCarport(CarportSaveParam carportSaveParam){
        log.debug("保存车位信息: carportSaveParam={}",carportSaveParam);
        carportService.saveCarport(carportSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{pid}")
    public JsonResult deleteCarport(@PathVariable Long pid){
        log.debug("删除车位信息: id={}",pid);
        carportService.deleteCarport(pid);
        return JsonResult.ok();
    }
}
